using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_SecUrl : Admin, IRequiresSessionState
{
	protected DropDownList QuickSearch;
	protected DropDownList ShopSearchClass;
	protected DropDownList DetailSearchType;
	protected TextBox DetailSearchName;
	protected Button SearchButton;
	protected GridView GridView1;
	protected Label PagePanel;
	protected Button DeleteBtn;
	protected Button Close_Button;
	protected Button btn_openSecUrl;
	private Shop_Shop _Shop = null;
	public string s_Class = "";
	public string s_QuickName = "";
	public string s_DetailType = "";
	public string s_DetailName = "";
	public bool m_tag = true;
	private string WhereStr = "";
	private string OrderbyStr = "";
	private string linkHead = "";
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected Shop_Shop m_Shop
	{
		get
		{
			Shop_Shop shop;
			if (this._Shop == null)
			{
				this._Shop = new Shop_Shop(this.conn);
				shop = this._Shop;
			}
			else
			{
				shop = this._Shop;
			}
			return shop;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(17))
		{
			base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "Shop");
			base.WriteRightErrMsg();
		}
		if (!base.IsPostBack)
		{
			this.BindClassDownList();
			this.BindList();
		}
	}
	protected void BindClassDownList()
	{
		Shop_Class shop_Class = new Shop_Class(this.conn);
		this.ShopSearchClass.DataSource = shop_Class.GetRootClass();
		this.ShopSearchClass.DataBind();
	}
	protected void QuickSearch_SelectedIndexChanged(object sender, EventArgs e)
	{
		this.m_tag = false;
		this.BindList();
	}
	protected void SearchButton_Click(object sender, EventArgs e)
	{
		this.m_tag = false;
		this.BindList();
	}
	protected void ShopSearchClass_SelectedIndexChanged(object sender, EventArgs e)
	{
		this.m_tag = false;
		this.BindList();
	}
	protected void BindList()
	{
		int num = Fetch.GetID("page");
		if (num == 0)
		{
			num = 1;
		}
		this.GetQuestString();
		int pagesize = 15;
		if (this.GridView1.PageSize != 0)
		{
			pagesize = int.Parse(this.GridView1.PageSize.ToString());
		}
		this.GridView1.DataSource = this.m_Shop.GetAllSecUrl(num, this.WhereStr, this.OrderbyStr, pagesize);
		this.GridView1.DataBind();
		this.PagePanel.Text = this.m_Shop.GetPagePanel(this.linkHead);
	}
	protected void GetQuestString()
	{
		this.s_QuickName = Fetch.Get("s_QuickName");
		if (this.s_QuickName != string.Empty && this.m_tag)
		{
			if (this.s_QuickName != "all")
			{
				this.linkHead = this.linkHead + "&s_QuickName=" + this.s_QuickName;
				this.QuickSearch.SelectedValue = this.s_QuickName;
			}
		}
		else
		{
			this.s_QuickName = this.QuickSearch.SelectedValue.ToString();
			if (this.s_QuickName != "all")
			{
				this.linkHead = this.linkHead + "&s_QuickName=" + this.s_QuickName;
			}
		}
		this.s_Class = Fetch.Get("s_Class");
		if (this.s_Class != string.Empty && this.m_tag)
		{
			if (this.s_Class != "-1")
			{
				this.WhereStr = this.WhereStr + "and ShopCategoryID=" + this.s_Class + " ";
				this.linkHead = this.linkHead + "&s_Class=" + this.s_Class;
				this.ShopSearchClass.SelectedValue = this.s_Class;
			}
		}
		else
		{
			this.s_Class = this.ShopSearchClass.SelectedValue.ToString();
			if (this.s_Class != "-1")
			{
				this.WhereStr = this.WhereStr + "and ShopCategoryID=" + this.s_Class + " ";
				this.linkHead = this.linkHead + "&s_Class=" + this.s_Class;
			}
		}
		this.s_DetailType = Fetch.Get("s_DetailType");
		if (this.s_DetailType != string.Empty && this.m_tag)
		{
			if (this.s_DetailType != "-1")
			{
				this.s_DetailName = Fetch.Get("s_DetailName");
				if (this.s_DetailName != string.Empty)
				{
					if (this.s_DetailType == "shop_name")
					{
						this.WhereStr = this.WhereStr + "and ShopName like '%" + this.s_DetailName + " ";
					}
					else
					{
						if (this.s_DetailType == "saler_name")
						{
							this.WhereStr = this.WhereStr + "and ShopOwnerName like '%" + this.s_DetailName + " ";
						}
						else
						{
							if (this.s_DetailType == "operate_item")
							{
								this.WhereStr = this.WhereStr + "and ShopOperatorItem like '%" + this.s_DetailName + " ";
							}
						}
					}
					string text = this.linkHead;
					this.linkHead = string.Concat(new string[]
					{
						text,
						"&s_DetailType=",
						this.s_DetailType,
						"&s_DetailName=",
						base.Server.UrlEncode(this.s_DetailName)
					});
					this.DetailSearchType.SelectedValue = this.s_DetailType;
					this.DetailSearchName.Text = this.s_DetailName;
				}
			}
		}
		else
		{
			this.s_DetailType = this.DetailSearchType.SelectedValue.ToString();
			if (this.s_DetailType != "-1")
			{
				this.s_DetailName = this.DetailSearchName.Text;
				if (this.s_DetailName != string.Empty)
				{
					if (this.s_DetailType == "shop_name")
					{
						this.WhereStr = this.WhereStr + "and ShopName like '%" + this.s_DetailName + "%' ";
					}
					else
					{
						if (this.s_DetailType == "saler_name")
						{
							this.WhereStr = this.WhereStr + "and ShopOwnerName like '%" + this.s_DetailName + "%' ";
						}
						else
						{
							if (this.s_DetailType == "operate_item")
							{
								this.WhereStr = this.WhereStr + "and ShopOperatorItem like '%" + this.s_DetailName + "%' ";
							}
						}
					}
					string text = this.linkHead;
					this.linkHead = string.Concat(new string[]
					{
						text,
						"&s_DetailType=",
						this.s_DetailType,
						"&s_DetailName=",
						this.s_DetailName
					});
				}
			}
		}
		if (this.s_QuickName != "all" && this.s_QuickName != string.Empty)
		{
			string text2 = this.s_QuickName;
			if (text2 != null)
			{
				if (!(text2 == "close"))
				{
					if (!(text2 == "normal"))
					{
						if (!(text2 == "pause"))
						{
							if (!(text2 == "three_day_open"))
							{
								if (text2 == "more_then_ten")
								{
									this.WhereStr += "and (select count(ProductID) from [HLShop_Product] Where HLShop_Product.ShopID=HLShop_Shop.ShopID)>10 ";
								}
							}
							else
							{
								this.WhereStr += "and datediff(d, ShopRegDate, getDate())<=3 ";
							}
						}
						else
						{
							this.WhereStr += "and ShopStatus=0 ";
						}
					}
					else
					{
						this.WhereStr += "and ShopStatus=1 ";
					}
				}
				else
				{
					this.WhereStr += "and ShopStatus=-1 ";
				}
			}
		}
		this.WhereStr += "and SecUrl<>''";
		if (this.WhereStr != "")
		{
			this.WhereStr = "and" + this.WhereStr;
			this.WhereStr = this.WhereStr.Replace("andand", "Where");
		}
	}
	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
			e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
		}
	}
	protected void btnOpeCommand(object sender, CommandEventArgs e)
	{
		string text = base.Request["chk_select"];
		if (!string.IsNullOrEmpty(text))
		{
			string commandName = e.CommandName;
			if (commandName != null)
			{
				if (!(commandName == "DeleteUrl"))
				{
					if (!(commandName == "CloseUrl"))
					{
						if (commandName == "OpenUrl")
						{
							this.m_Shop.OpenOrCloseSecUrl(text, "1");
							base.WriteLog("Check", Language.GetAdminMsg("Log/ObjectID", text), "ShopDomain");
							this.BindList();
						}
					}
					else
					{
						this.m_Shop.OpenOrCloseSecUrl(text, "0");
						base.WriteLog("Check", Language.GetAdminMsg("Log/ObjectID", text), "ShopDomain");
						this.BindList();
					}
				}
				else
				{
					this.m_Shop.deleteSecUrlByShopID(text);
					base.WriteLog("Delete", Language.GetAdminMsg("Log/ObjectID", text), "ShopDomain");
					this.BindList();
				}
			}
		}
	}
}
